//
//  WHLoginView.m
//  WHPersonalData
//
//  Created by shengmeng chen on 2021/7/28.
//  Copyright © 2021 mac. All rights reserved.
//

#import "WHLoginView.h"
#import "HJDropDownMenu.h"

@interface WHLoginView ()<UITextFieldDelegate>

@property(nonatomic,weak)UIImageView *appIcon;
/**  企业    **/
@property (nonatomic,weak)UILabel*companyLabel;
/**  企业   **/
@property(nonatomic,weak) HJDropDownMenu *companyDownMenu;
/**  港号   **/
@property(nonatomic,weak)UILabel*qcodeLabel;
/**  港号   **/
@property(nonatomic,weak)UITextField*qcodeField;
/**  密码    **/
@property(nonatomic,weak)UILabel*passwordLabel;
/**  密码   **/
@property(nonatomic,weak)UITextField*passwordField;
/**  登陆    **/
@property(nonatomic,weak)UIButton *loginBtn;
/**  申请港号   **/
@property(nonatomic,weak)UIButton * qcodeBtn;
/**  忘记密码   **/
@property(nonatomic,weak)UIButton * passwordBtn;
/**  协议   **/
@property(nonatomic,weak)UIButton * protolBtn;

@end

@implementation WHLoginView

-(void)createUIControls
{
    [super createUIControls];
    [self setUpSubView];
    [self setUpUIControlsLayout];
}

-(void)setUpSubView
{
    /**   图片   **/
    UIImageView*appIcon =[[UIImageView alloc]init];
    [self  addSubview:appIcon];
    appIcon.layer.cornerRadius = 4;
    appIcon.layer.borderWidth = 0.5;
    appIcon.layer.borderColor =[UIColor lightGrayColor].CGColor;
    _appIcon = appIcon;
    
    /** 企业   **/
    UILabel * companyLabel= [[UILabel alloc]init];
    companyLabel.textColor =RGBColor(97, 98, 99);
    companyLabel.text = @"企业:";
    companyLabel.font = [UIFont systemFontOfSize:15*WidthScale>18?18:15*WidthScale];
    [self addSubview:companyLabel];
    _companyLabel = companyLabel;

    /**  港号  **/
    UILabel * qcodeLabel= [[UILabel alloc]init];
    qcodeLabel.textColor =RGBColor(97, 98, 99);
    qcodeLabel.text = @"港号:";
    qcodeLabel.font = [UIFont systemFontOfSize:15*WidthScale>18?18:15*WidthScale];
    [self addSubview:qcodeLabel];
    _qcodeLabel = qcodeLabel;
    
    /**  港号   **/
    UITextField*qcodeField =[[UITextField alloc]init];
    qcodeField.font = [UIFont systemFontOfSize:13*WidthScale>16?16:13*WidthScale];
    qcodeField.tag = 201;
    qcodeField.backgroundColor = [UIColor whiteColor];
    _qcodeField = qcodeField;
    [self addSubview:qcodeField];
    qcodeField.delegate = self;
    qcodeField.layer.cornerRadius = 4;
    qcodeField.layer.borderWidth = 0.5;
    qcodeField.layer.borderColor =[UIColor lightGrayColor].CGColor;
    
    /**  密码  **/
    UILabel *passwordLabel= [[UILabel alloc]init];
    passwordLabel.textColor =RGBColor(97, 98, 99);
    passwordLabel.text = @"密码:";
    passwordLabel.font = [UIFont systemFontOfSize:15*WidthScale>18?18:15*WidthScale];
    [self addSubview:passwordLabel];
    _passwordLabel = passwordLabel;
    
    /**  港号   **/
    UITextField*passwordField =[[UITextField alloc]init];
    passwordField.font = [UIFont systemFontOfSize:13*WidthScale>16?16:13*WidthScale];
    passwordField.tag = 201;
    passwordField.backgroundColor = [UIColor whiteColor];
    _passwordField = passwordField;
    [self addSubview:passwordField];
    passwordField.delegate = self;
    passwordField.layer.cornerRadius = 4;
    passwordField.layer.borderWidth = 0.5;
    passwordField.layer.borderColor =[UIColor lightGrayColor].CGColor;
    
    /**  登陆   **/
    UIButton*loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [loginBtn setTitle:@"登陆" forState:UIControlStateNormal];
    [loginBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    loginBtn.layer.cornerRadius = 4;
    loginBtn.layer.borderWidth = 0.5;
    loginBtn.layer.borderColor =[UIColor lightGrayColor].CGColor;
    [self  addSubview:loginBtn];
    _loginBtn = loginBtn;
    
    /**  申请港号   **/
    UIButton*qcodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [qcodeBtn setTitle:@"申请港号" forState:UIControlStateNormal];
    [qcodeBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    qcodeBtn.layer.cornerRadius = 4;
    qcodeBtn.layer.borderWidth = 0.5;
    qcodeBtn.layer.borderColor =[UIColor lightGrayColor].CGColor;
    [self  addSubview:qcodeBtn];
    _qcodeBtn = qcodeBtn;
    
    /**  忘记密码   **/
    UIButton*passwordBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [passwordBtn setTitle:@"忘记密码" forState:UIControlStateNormal];
    [passwordBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    passwordBtn.titleLabel.font =[UIFont systemFontOfSize:13];
    [self  addSubview:passwordBtn];
    _passwordBtn = passwordBtn;
    
    /**  协议   **/
    UIButton*protolBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [protolBtn setTitle:@"我已阅读并同意xxxx条款及xxxx用户协议，隐私政策" forState:UIControlStateNormal];
    [protolBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    protolBtn.titleLabel.font =[UIFont systemFontOfSize:13];
    [self  addSubview:protolBtn];
    _protolBtn= protolBtn;
    
    /**  数据类型     **/
    HJDropDownMenu * companyDownMenu = [[HJDropDownMenu alloc] init];
    companyDownMenu.rowHeight = kMarginH*3;
    companyDownMenu.autoCloseWhenSelected =YES;
    [self addSubview:companyDownMenu];
    _companyDownMenu = companyDownMenu;
     _companyDownMenu.datas =@[@"新瓴态企业发展(上海)",@"价值链(深圳)有限公司"];
    companyDownMenu.cellClickedBlock = ^(NSString *title, NSInteger index)
    {
    
    };
}

-(void)setUpUIControlsLayout
{
    [super setUpUIControlsLayout];
    
    _appIcon.frame = CGRectMake( ScreenW/2- kMarginH*2.5,kMarginH*10, kMarginH*8,kMarginH*8);
    /**  企业  **/
    _companyLabel.frame  =CGRectMake(kMarginW*4,CGRectGetMaxY(_appIcon.frame)+kMarginH*4, kMarginW*6,kMarginH*3);
    /**  企业  **/
    _companyDownMenu.frame=CGRectMake(kMarginW*13, CGRectGetMaxY(_appIcon.frame)+kMarginH*4, kMarginW*22,kMarginH*10);
    
    _qcodeLabel.frame  =CGRectMake(kMarginW*4,CGRectGetMaxY(_companyLabel.frame)+kMarginH, kMarginW*6,kMarginH*3);
    
    _qcodeField.frame=CGRectMake(kMarginW*13, CGRectGetMaxY(_companyLabel.frame)+kMarginH, kMarginW*22,kMarginH*3);

    _passwordLabel.frame  =CGRectMake(kMarginW*4,CGRectGetMaxY(_qcodeLabel.frame)+kMarginH, kMarginW*6,kMarginH*3);

    _passwordField.frame=CGRectMake(kMarginW*13, CGRectGetMaxY(_qcodeLabel.frame)+kMarginH, kMarginW*22,kMarginH*3);
    
    _loginBtn.frame=CGRectMake(kMarginW*2, CGRectGetMaxY(_passwordLabel.frame)+kMarginH*3, ScreenW-kMarginW*4,kMarginH*4);
    
    _qcodeBtn.frame=CGRectMake(kMarginW*2, CGRectGetMaxY(_loginBtn.frame)+kMarginH, ScreenW-kMarginW*4,kMarginH*4);
    
    _passwordBtn.frame=CGRectMake(ScreenW-kMarginW*9, CGRectGetMaxY(_qcodeBtn.frame)+kMarginH, kMarginW*8,kMarginH*2);
    
    _protolBtn.frame=CGRectMake(kMarginW*2, CGRectGetMaxY(_passwordBtn.frame)+kMarginH*10, ScreenW-kMarginW*4,kMarginH*2);
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    

}

@end
